var aid = GetQueryString('aid') || '';
var xcx_openid = GetQueryString('xcx_openid') || '';
var wx_openid = GetQueryString('wx_openid') || '';
var token = GetQueryString('token') || '';
if(isEmpty(aid) || (isEmpty(xcx_openid) && isEmpty(wx_openid)) || isEmpty(token)){
    malert("非法操作", function () {
        if (is_local) {
            locationReplace('index.html');
        } else {
            wx.miniProgram.redirectTo({url: '/pages/index/index'})
        }
    });
} else {
    var success = function (res) {
        var info = res.data;
        var html = template('shop_list', info);
        $('#shop_list_content').append(html);

        var sid = null;
        //点击选择店铺
        $('.shop_change').on('tap', function () {
            var radio = $(this).find('.radio');
            sid = radio.val();
            if (sid == undefined || sid == null || sid === '') {
                return;
            }
            $('.buttom_fixed').removeClass('un_choosed');
            $('#radio' + sid).prop('checked', 'checked').attr('checked',true);
            $("#sid").val(sid);
        })

        var ajaxOption = {
            url: member_bind_shop,
            method: 'POST',
            confirm:true,
            confirm_title: '提示',
            confirm_content: '确定选择绑定该店铺',//用[]包起来表示该值是函数，不包则为字符串
            data: {aid: aid, xcx_openid: xcx_openid,wx_openid:wx_openid,token: token},
            success: function (res) {
                setTimeout(function () {
                    var info = res.data;
                    if (!isEmpty(info)) {
                        var obj = {
                            'shop_name': info.shop_name,
                            'sid': info.sid,
                            'xcx_openid': info.xcx_openid,
                            'wx_openid':info.wx_openid,
                            aid: info.aid
                        };
                        setCache(login_key, obj);
                        locationReplace('take-water.html?xcx_openid=' + xcx_openid + '&wx_openid=' + wx_openid +'&sid=' + info.sid);
                    }
                }, 2000);
            }
        }
        checkform($('#myform'), ajaxOption);
    }
    getData(shop_index, {aid: aid, xcx_openid: xcx_openid,wx_openid:wx_openid, token: token}, success);
}